<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑会员</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>`
<body>

<div class="layui-form layuimini-form" lay-filter="newsEditFormFilter">

    <input type="hidden" name="oldNewsId" value="">
    <div class="layui-form-item">
        <label class="layui-form-label required">主键编号</label>
        <div class="layui-input-block">
            <input type="text" name="newsId" lay-verify="required" lay-reqtext="主键编号不能为空" placeholder="请输入主键编号"
                   value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">资讯标题</label>
        <div class="layui-input-block">
            <input type="text" name="newsTitle" lay-verify="required" lay-reqtext="资讯标题不能为空" placeholder="请输入资讯标题"
                   value=""
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">资讯内容</label>
        <div class="layui-input-block">
            <input type="text" name="newsContent"  lay-verify="required"  lay-reqtext="资讯内容不能为空" placeholder="请输入资讯内容"
                   value=""
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">创建时间</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="createTime" name="createTime">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>

<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>

    var data;
    function child(data){
        this.data = data;

        layui.use(['form','element','laydate'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var element = layui.element;
            var laydate = layui.laydate;
            var $ = layui.$;

            laydate.render({
                elem:'#registerTime'
                ,format: 'yyyy-MM-dd HH:mm:ss',
                value: new Date(),
            })

            //初始化表单
            form.val("newsEditFormFilter", {
                "oldMemberId":data.newsId,
                "newsId": data.newsId,
                "newsContent": data.newsContent,
                "newsTitle": data.newsTitle,
                "createTime": data.createTime
            });


            //监听提交
            form.on('submit(saveBtn)', function (data) {
                //打印表单数据
                console.log(data.field);

                var data=form.val("newsEditFormFilter");

                $.ajax({

                    contentType : "application/json",
                    data: JSON.stringify(data),
                    dataType:"json",
                    type:"post",
                    url: "/wfx_manager/news/editNews",
                    success: function (res) {
                        if (res.flag){
                            layer.msg(res.msg,function () {
                                //获取iframe的唯一标识
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                //关闭iframe窗口
                                parent.layer.close(iframeIndex);
                                //将表单中的数据传递到villagelist
                                parent.parent(form.val("newsEditFormFilter"));
                            })
                        }
                        layer.msg(res.msg);
                    }
                })
                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

                return false;
            });



        });

    }

</script>
</body>
</html>